version: '3'

services:
  webapp:
    build:
      context: .
      dockerfile: Dockerfile
    command: ./script.sh
    volumes:
      - ./:/usr/src/welbex/
    ports:
      - 8000:8000
    depends_on:
      - web_db
    env_file:
      - .env
    container_name: webapp
    networks:
      - djangoproject_network

  web_db:
    image: postgres:14
    volumes:
      - postgres_volume:/var/lib/postgresql/data/
    ports:
      - ${db_port}:${db_port}
    environment:
      - POSTGRES_USER=${db_user}
      - POSTGRES_PASSWORD=${db_pass}
      - POSTGRES_DB=${db_name}
    container_name: web_db
    networks:
      - djangoproject_network


  scri:
    build:
      context: .
      dockerfile: Dockerfile.script
    command: ./script_upload.sh
    depends_on:
      - webapp
    volumes:
      - ./:/usr/src/welbex/
    env_file:
      - .env
    networks:
      - djangoproject_network

volumes:
  postgres_volume:

networks:
  djangoproject_network:
    driver: bridge